package com.viu.technology.dao.product;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.viu.technology.dao.BaseDao;
import com.viu.technology.mapper.ProductMapper;
import com.viu.technology.mapper.ProductStatisMapper;
import com.viu.technology.po.Order;
import com.viu.technology.po.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class ProductDaoImpl extends BaseDao implements ProductDao {

    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private ProductStatisMapper productStatisMapper;

    public Product selectProductById(String id) {
        return productMapper.selectByPrimaryKey(id);
    }

    public int insertProduct(Product product) {
        return productMapper.insertSelective(product);
    }

    public int insertProductStatis(String id) {
        return productStatisMapper.insert(id);
    }

    public int updateProductStockPessimism(Order order) {
        return productMapper.updateProductStockPessimism(order);
    }

    public int updateProductStockPessimismNotImpose(Order order) {
        return productMapper.updateProductStockPessimismNotImpose(order);
    }

    @Override
    public PageInfo<Product> selectAllProductWithPage() {
        //PageHelper.startPage(getPageNum(), getPageSize());
        return new PageInfo<>(productMapper.selectAllProduct());
    }


}
